#include<bits/stdc++.h>
#define ll long long
#define For(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
inline int read(){
    int sum = 0, fh = 1; char ch = getchar();
    while (!isdigit(ch)) {if (ch == '-') fh = -1; ch = getchar();}
    while (isdigit(ch)) {sum = sum * 10 + ch - '0'; ch = getchar();}
    return sum * fh;
}
inline void write(int x){
    if (x == 0){putchar('0'); return ;}stack<char> s;
    if (x < 0) {putchar('-'); x = -x;}
    while(x) {s.push(x % 10 + '0'); x /= 10;}
    while(!s.empty()) {putchar(s.top()); s.pop();}
}
const int MAXN = 1e5 + 10;
int n, a[MAXN], c[MAXN], ans = 0;
int solve()
{
    int ret = 0;
    For(i, 1, n)
    {
        for (int j = i - 1; j >= 1; j--)
        {
            if (a[j] == a[i] && c[j] == c[i])
            {
                ret += a[i];
            }
        }
    }
    return ret;
}
void dfs(int x)
{
    if (x > n)
    {
        ans = max(solve(), ans);
        return ;
    }
    c[x] = 0;
    dfs(x + 1);
    c[x] = 1;
    dfs(x + 1);
}
signed main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int T = read();
    while(T--)
    {
        n = read();
        For(i, 1, n)
        {
            a[i] = read();
        }
        ans = 0;
        dfs(1);
        write(ans);
        putchar('\n');
    }
    return 0;
}